package com.mgface.framework.client.filter;

import java.io.IOException;
import java.util.List;
import java.util.Map.Entry;

import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientResponseContext;
import javax.ws.rs.client.ClientResponseFilter;

public class ClientResponseFilterWrapper implements ClientResponseFilter {

	public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
		System.out.println("status: " + responseContext.getStatus());
        System.out.println("date: " + responseContext.getDate());
        System.out.println("last-modified: " + responseContext.getLastModified());
        System.out.println("location: " + responseContext.getLocation());
        System.out.println("headers:");
//        ArrayList<String> list = responseContext.getHeaders().entrySet().parallelStream()
//        		.map(e->e.getKey()+"->"+e.getValue()).collect(Collectors.toCollection(ArrayList::new));
//        System.out.println(list);
        for (Entry<String, List<String>> header : responseContext.getHeaders().entrySet()) {
            System.out.print("\t" + header.getKey() + " :");
            for (String value : header.getValue()) {
                System.out.print(value + ",");
            }
            System.out.print("\n");
        }
        System.out.println("media-type: " + responseContext.getMediaType().getType());
	}

}
